package com.jianneng.jdg.model.homeactivity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.user.ActivitiesInfo;

public class ActivitiesDetailsActivity extends BaseActivity {
private ImageView mDetailImage;
private TextView mDetailContent;
private LinearLayout mBack;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_activities_details);
		init();
		Intent intent = getIntent();
		ActivitiesInfo info = (ActivitiesInfo) intent.getSerializableExtra("activity_detail");
		mDetailContent.setText(info.getContent());
		if(info.getImage()!=null){
			
			mDetailImage.setImageBitmap(getBitmapFromString(info.getImage()));
		}
		mBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
				
			}
		});
	}
	private void init() {
		mDetailImage = (ImageView) findViewById(R.id.activity_details_img);
		mDetailContent = (TextView) findViewById(R.id.activity_detail_content);
		mBack = (LinearLayout) findViewById(R.id.activities_details_back);
	}
	public Bitmap getBitmapFromString(String str){
		byte[] bytes = str.getBytes();
		   if(bytes.length!=0){  
               return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);  
           }  
           else {  
               return null;  
           }  
	}
}
